<?php
	/*
		PandaForum: PHP Forum Engine
		
		Jesse Gill, 0108377707
	*/
	
	require_once('./src/classes/Structure.php');
	require_once('./src/classes/DBConnection.php');
	require_once('./src/classes/LocalUser.php');
	
	class Page
	{
		private $structure = false;
		private $name = '';
		
		public $connection = false;
		public $curUser = false;
		
		function __construct($name)
		{
			require('./src/config.php');
			
			$this->name = $name;
			$this->connection = new DBConnection();
			$this->connection->connect($host, $username, $password, $dbname);
			
			if (! $this->connection->is_connected())
			{
				echo $this->connection->get_error();
				
				$this->connection = false;
			}
			else
			{
				$this->curUser = new LocalUser($this->connection);
				$this->curUser->update_last_active($this->connection);
			}
			
			$this->structure = new Structure($this->name);
		}
		
		function __destruct()
		{
			if ($this->connection)
			{
				$this->connection->close();
			}
		}
		
		function print_header()
		{
			if ($this->structure)
			{
				$this->structure->print_header($this->curUser);
			}
			else
			{
				// error
			}
		}
		
		function print_footer()
		{
			if ($this->structure)
			{
				$this->structure->print_footer();
			}
			else
			{
				// error
			}
			
			if ($this->connection)
			{
				$this->connection->close();
			}
		}
		
		function print_acp_nav()
		{
			if ($this->structure)
			{
				$this->structure->print_acp_nav();
			}
			else
			{
				// error
			}
		}
		
		function print_ucp_nav()
		{
			if ($this->structure)
			{
				$this->structure->print_ucp_nav();
			}
			else
			{
				// error
			}
		}
	}
?>